﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Things.Bar.Models;
using Things.Bar;

namespace Things.Web.GoodBar
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //List<NoticeType> types = new NoticeTypeRepository().FindAll();
                //_ctlTypeList.DataSource = types;
                //_ctlTypeList.DataBind();

                //if(types.Count>0)
                //{
                //    _ctlNoticeList.DataSource = types[0].Notice.ToList<Notice>();
                //    _ctlNoticeList.DataBind();
                //}

                Guid typeId = Guid.Empty;
                try
                {
                    typeId = new Guid(Request["type"]);
                    List<Notice> notices = new NoticeRepository().FindAll(typeId);
                    DataList1.DataSource = notices;
                    DataList1.DataBind();
                }
                catch
                {
                    List<Notice> notices = new NoticeRepository().FindAll();
                    DataList1.DataSource = notices;
                    DataList1.DataBind();
                }
            }
        }
    }
}